//
//  ASSearchTitleView.m
//  AvatarShow
//
//  Created by xunruiIOS on 2021/4/28.
//

#import "ASSearchTitleView.h"

@implementation ASSearchTitleView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.titleLab];
        [self addSubview:self.clearBtn];
        [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.mas_centerY);
            make.left.mas_equalTo(14);
        }];
        
        [self.clearBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.mas_centerY);
            make.right.mas_equalTo(-20);
        }];
    }
    return self;
}

- (UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [[UILabel alloc]init];
        _titleLab.textColor = [UIColor colorWithHexString:@"#FF7785"];
        _titleLab.font = [UIFont systemFontOfSize:16];
    }
    return _titleLab;
}

- (UIButton *)clearBtn{
    if (!_clearBtn) {
        _clearBtn = [UIButton new];
        _clearBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [_clearBtn setTitleColor:[UIColor colorWithHexString:@"#1A1A1A"] forState:UIControlStateNormal];
        [_clearBtn addTarget:self action:@selector(clickClearBtn) forControlEvents:UIControlEventTouchUpInside];
    }
    return _clearBtn;
}

- (void)clickClearBtn{
    if (self.cleanBtnBlock) {
        self.cleanBtnBlock(self.index);
    }
}
@end
